// 继承Exception：受查异常
// 继承RuntimeException：非受查异常
class NameException extends RuntimeException{
    public NameException(String massage){
        super(massage);
    }
}
class PasswordException extends RuntimeException{
    public PasswordException(String massage){
        super(massage);
    }
}
public class Login {
    private static String name = "marry";
    private static String password = "123456";
    public static void login(String name,String password){
        if(!name.equals(Login.name)){
            throw new NameException("用户名错误");
        }
        if(!password.equals(Login.password)){
            throw new PasswordException("密码错误");
        }
        System.out.println("登录成功！");
    }
    public static void main(String[] args) {
        try {
            Login.login("marry","12345");
        } catch (NameException e) {
            System.out.println("用户名错误！");
        }catch (PasswordException e){
            System.out.println("密码错误！");
        }
    }
}
